<?php /* УТФ-8:fix */

class SPItpl
{
    static private $instances = array();

    static public function I( $tpl_id )
    {
        //---------------------------------------------------------------------
        // Check if created before -> then return

        if( ! isset( self::$instances[$tpl_id] ) )
        {
            $tplcfg = SPIcfg::$tpl[$tpl_id];

            switch( strtoupper( $tplcfg['type'] ) )
            {
                case 'SMARTY':
                {
                    require_once SPIcfg::$util['smarty']['base_script'];

                    if( class_exists( SPItpl__smarty ) === false )
                    {
                        return false;
                    }

                    self::$instances[$tpl_id] = new SPItpl__smarty($tplcfg);
                    break;
                }
            }
        }

        return self::$instances[$tpl_id];
    }
}
